package com.zzcy.bt_print_plugin.utils;

import android.animation.ObjectAnimator;
import android.widget.ImageView;

/**
 * @author: dhd
 * @date: 2023/10/26
 * Describe : 写点什么解释一下这个类
 */
public class AnimatorUtil {
    private static ObjectAnimator objectAnimator;

    /**
     * ImageView 旋转
     *
     * @param imageView
     * @param duration
     * @param angle
     */
    public static void rotate(ImageView imageView, int duration, Float angle) {
        cancelAnimator();
        objectAnimator = ObjectAnimator.ofFloat(imageView, "rotation", angle, 0f);
        objectAnimator.setDuration(duration).start();
    }

    public static void cancelAnimator() {
        if (objectAnimator != null) {
            objectAnimator.cancel();
            objectAnimator = null;
        }
    }
}
